
package com.library.book.service;

public class Bookcategoryservice {

    private BookInfoMapper bookInfoMapper;

    public PageInfo<BookInfo> queryBookInfoAll(BookInfo bookInfo, Integer pageNum, Integer limit) {
        PageHelper.startPage(pageNum,limit);
        List<BookInfo> bookInfoList = bookInfoMapper.queryBookInfoAll(bookInfo);
        return new PageInfo<>(bookInfoList);
    }

    public void addBookSubmit(BookInfo bookInfo) {
        bookInfoMapper.insert(bookInfo);
    }

    public BookInfo queryBookInfoById(Integer id) {
        return bookInfoMapper.selectByPrimaryKey(id);
    }

    public void updateBookSubmit(BookInfo info) {
        bookInfoMapper.updateByPrimaryKeySelective(info);
    }

    public void deleteBookByIds(List<String> ids) {
        for (String id : ids){
            bookInfoMapper.deleteByPrimaryKey(Integer.parseInt(id));
        }
    }

    public List<BookInfo> getBookCountByType() {
        return bookInfoMapper.getBookCountByType();
    }
}
